package com.clinic.entity.db;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import com.clinic.entity.type.GenderType;

@Entity
@Table(name = Patient.TABLE)
@PrimaryKeyJoinColumn(name = User.Columns.USER_ID)
public class Patient extends User implements Serializable {

	private static final long serialVersionUID = -6730008091822979620L;
	
	public static final String TABLE = "patient";

	public class Columns {
		public static final String PATIENT_ID = "patientId";
		public static final String DOB = "dob";
		public static final String GENDER = "gender";
	}
	
	@Column(name = Columns.DOB)
	private Date dob;
	
	@Enumerated(EnumType.STRING)
	@Column(name = Columns.GENDER)
	private GenderType gender;
	
	@OneToMany(mappedBy="patient", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
    private List<Appointment> appointments;
	
	@OneToMany(mappedBy="patient", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
    private List<Prescription> prescriptions;
	
	public Date getDob() {
		return dob;
	}

	public void setDob(Date dob) {
		this.dob = dob;
	}

	public GenderType getGender() {
		return gender;
	}

	public void setGender(GenderType gender) {
		this.gender = gender;
	}

	public List<Appointment> getAppointments() {
		return appointments;
	}

	public void setAppointments(List<Appointment> appointments) {
		this.appointments = appointments;
	}

	public List<Prescription> getPrescriptions() {
		return prescriptions;
	}

	public void setPrescriptions(List<Prescription> prescriptions) {
		this.prescriptions = prescriptions;
	}

}
